# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Patryk Kowalczyk < patryk at kowalczyk dot ws>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - upstream patch to fix FTBFS

pkgname=spice
pkgver=0.14.3
pkgrel=3
pkgdesc="SPICE server"
arch=('x86_64')
url="https://www.spice-space.org"
license=('LGPL2.1')
depends=('pixman' 'opus' 'libjpeg-turbo' 'glib2' 'libsasl' 'lz4')
makedepends=('meson' 'spice-protocol' 'libcacard')
checkdepends=('gdk-pixbuf2' 'glib-networking')
provides=('libspice-server.so')
source=("https://www.spice-space.org/download/releases/spice-server/$pkgname-$pkgver.tar.bz2"{,.sign}
        'https://gitlab.freedesktop.org/spice/spice/-/commit/26bbb85c150f882c05399e4c574208b8b1242082.diff')
sha256sums=('551d4be4a07667cf0543f3c895beb6da8a93ef5a9829f2ae47817be5e616a114'
            'SKIP'
            '9ba4063f8455fbbaad1fb35610e2cd4bcb2beaa646522a2aa6504a840a8a0098')
validpgpkeys=('206D3B352F566F3B0E6572E997D9123DE37A484F') # Victor Toso <victortoso@redhat.com>

prepare() {
  sed -i "s/if not version_info.contains('git')/if version_info.length() >= 4/" $pkgname-$pkgver/server/meson.build
  cd $pkgname-$pkgver
  patch -p1 -i ../26bbb85c150f882c05399e4c574208b8b1242082.diff
}

build() {
  arch-meson "$pkgname-$pkgver" build -D gstreamer=no
  ninja -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  DESTDIR="$pkgdir" meson install -C build
}
